home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 101-125 / scopedisk122 / bassub / listselector.sub < prev    next >
Text File  |  1995-03-19  |  4KB  |  142 lines

  1. REM ListSelector
  2. ' These three subroutines make up a simple list selection requestor
  3. ' Define the list selector with ListSelector
  4. ' Initialize the requestor with SetList
  5. ' Make selections by calling GetSelection
  6. '
  7. ' These subroutines require the Intuits subroutines for gadgets
  8. '
  9. SUB ListSelector(x%,y%,kw$(1),idx%(1),title$,dx%)
  10. ' x% = horizontal pixel offset to locate selector
  11. ' y% = vertical pixel offset to locate selector
  12. ' kw$() = 1 dimensional array containing list elements (Max. 20 chars.)
  13. ' idx%() = 1 dimensional array to hold subscripts to kw$() (returned values)
  14. ' title$ = a title string (25 characters)
  15. ' dx% = beginning gadget number
  16. '
  17. ' List Selector is 230 pix wide by 105 pix high
  18. '
  19. ' Requires use of Intuits.SUB/Intuits.Header
  20. '
  21.     SHARED x1%(),y1%()
  22.     j%=y%+18 : BoxIndex%=dx% : count%=0 : numsel%=0 : tj%=0 : tot%=0 : Ptr%=0
  23.     nk%=n%-(n% MOD 6)
  24.     LINE (x%,y%+3)-(x%+230,y%+105),3,b
  25.     LINE (x%+2,y%+4)-(x%+229,y%+104),2,b
  26.     LINE (x%+3,y%+4)-(x%+228,y%+104),2,b
  27.     LINE (x%+6,y%+6)-(x%+225,y%+102),1,bf
  28.     LINE (x%+10,j%+3)-(x%+200,j%+64),2,bf
  29.     COLOR 3,1,0
  30.     PRINT PTAB(x%+((230-LEN(title$)*8)/2),y%+16);title$
  31.     COLOR 2,1,0
  32.     FOR i%=1 TO 6
  33.         INCR count%
  34.         PRINT PTAB(x%+18,j%+10*count%) : CALL SmallTxGad(SPACE$(20))
  35.     NEXT i%
  36.     COLOR 0,1,0
  37.     ' Make UP arrow
  38.     area (x%+214,y%+22)
  39.     area step (9,4)
  40.     area step (-19,0)
  41.     area step (9,-4)
  42.     areafill 0
  43.     line (x%+214,y%+27)-(x%+214,y%+30),0
  44.     ' Make DOWN arrow
  45.     area (x%+214,y%+80)
  46.     area step (-10,-4)
  47.     area step (19,0)
  48.     area step (-9,4)
  49.     areafill 0
  50.     line (x%+214,y%+72)-(x%+214,y%+75),0
  51.     COLOR 0,1,0
  52.     PRINT PTAB(x%+202,y%+29) : CALL SmallTxBox(" ")
  53.     PRINT PTAB(x%+8,y%+95) : CALL SmallTxBox("OK")
  54.     PRINT PTAB(x%+159,y%+95) : CALL SmallTxBox("Cancel")
  55.     PRINT PTAB(x%+202,y%+79) : CALL SmallTxBox(" ")
  56.     COLOR 2,1,0
  57. END SUB
  58. SUB SetList(k$(1),ix%(1),m%,w%,l%,nk%,tot%,n%)
  59. 'm% = beginning gadget number, usually 1
  60. 'n% = number of elements in array k$()
  61. 'all other parameters are passed from GetSelection
  62. '
  63.     SHARED x1%(),y1%()    'from gadgets subroutines
  64.         w%=l%*6
  65.         lj%=l%+1
  66.         IF nk%=0 THEN
  67.             kk%=n% MOD 6
  68.             DECR lj%
  69.         END IF
  70.         COLOR 2,2,1
  71.         FOR i%=m% TO m%+5
  72.             PRINT PTAB(x1%(i%)-8,y1%(i%)+8);SPACE$(23)
  73.         NEXT i%
  74.         COLOR 1,2,0
  75.         FOR i%=m% TO m%+5
  76.             PRINT PTAB(x1%(i%)+8,y1%(i%)+8);k$(i%+w%-m%)
  77.             FOR jj%=1 TO tot%
  78.                 IF ix%(jj%)-w%+1=i% THEN
  79.                     CALL CheckBox(i%,1)
  80.                 END IF
  81.             NEXT jj%
  82.             COLOR 1,2,0
  83.         NEXT i%
  84. END SUB
  85. SUB GetSelection(kw$(),idx%(),m%,w%,l%,nk%,tot%,n%,numsel%)
  86. 'n% = number of elements in array kw$()
  87. 'numsel% = returns the number of selected items
  88. 'idx%() = contains index of array elements selected
  89. 'm% = beginning gadget number
  90. 'other parameters are needed to pass to SetList
  91. '
  92.     start%=m%-1
  93.     nk%=n%-(n% MOD 6)
  94.     DO
  95.         CALL WaitBox(which%)
  96.         CALL FlashRelease(which%)
  97.         SELECT CASE which%
  98.             CASE start%+10
  99.                 nk%=nk%-6
  100.                 IF l%<n%\6 THEN INCR l%
  101.                 CALL SetList(kw$(),idx%(),1,w%,l%,nk%,tot%,n%)
  102.             CASE start%+9
  103.                 COLOR 0,1,0
  104.                 FOR i%=1 TO n%
  105.                     idx%(i%)=-1
  106.                 NEXT i%
  107.                 CALL SetList(kw$(),idx%(),1,w%,l%,nk%,tot%,n%)
  108.                 numsel%=0
  109.                 COLOR 1,0,1
  110.                 EXIT SUB
  111.             CASE start%+8
  112.                 COLOR 1,0,1
  113.                 FOR jj%=1 TO tot%
  114.                     IF idx%(jj%)=-1 THEN
  115.                         INCR Ptr%
  116.                     ELSE
  117.                         idx%(jj%-Ptr%)=idx%(jj%)
  118.                         INCR numsel%
  119.                     END IF
  120.                 NEXT jj%
  121.                 EXIT SUB
  122.             CASE start%+7
  123.                 nk%=nk%+6
  124.                 IF l%>0 THEN DECR l%
  125.                 CALL SetList(kw$(),idx%(),1,w%,l%,nk%,tot%,n%)
  126.             CASE start%+1 TO start%+6
  127.                 IF which%<>last% THEN INCR tot%
  128.                 CALL CheckBox(which%,1)
  129.                 FOR tj%=1 TO tot%
  130.                     IF idx%(tj%)=which%+w%-m% THEN
  131.                         idx%(tj%)=-1
  132.                         tj%=1
  133.                         EXIT SELECT
  134.                     END IF
  135.                 NEXT tj%
  136.                 idx%(tot%)=which%+w%-m%
  137.                 last%=which%
  138.         END SELECT
  139.     LOOP
  140. END SUB
  141.  
  142.